﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DeThi1
{
    public partial class frmTimKiemBaiHat : Form
    {
        TruyXuatDuLieu txdl;
        public frmTimKiemBaiHat()
        {
            InitializeComponent();
            string strChuoiKetNoi = "provider = microsoft.jet.oledb.4.0;data source = QuanLyBaiHat.mdb;";
            txdl = new TruyXuatDuLieu(strChuoiKetNoi);
            txdl.MoKetNoi();
        }

        private void btnXong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            clsBaiHat baihat = new clsBaiHat();
            baihat = clsBaiHat.TimKiemBaiHat(txdl, txtMaBaiHat.Text);

            txtTenBaiHat.Text = baihat.TENBAIHAT;
            txtLoiBaiHat.Text = baihat.LOIBAIHAT;
            txtTacGia.Text = baihat.TACGIA;
            txtTenAlbum.Text = baihat.TENALBUM;
            if (txtTenBaiHat.Text == "")
            {
                MessageBox.Show("Không tìm thấy bài hát!");
            }
        }

        private void txtMaBaiHat_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                clsBaiHat baihat = new clsBaiHat();
                baihat = clsBaiHat.TimKiemBaiHat(txdl, txtMaBaiHat.Text);

                txtTenBaiHat.Text = baihat.TENBAIHAT;
                txtLoiBaiHat.Text = baihat.LOIBAIHAT;
                txtTacGia.Text = baihat.TACGIA;
                txtTenAlbum.Text = baihat.TENALBUM;
                if (txtTenBaiHat.Text == "")
                {
                    MessageBox.Show("Không tìm thấy bài hát!");
                }
            }
        }
    }
}